
#define CLIP        320
#define RED_NULL    128
#define BLUE_NULL   128
#define LUN_MUL     256
#define RED_MUL     512
#define BLUE_MUL    512
#define GREEN1_MUL  (-RED_MUL/2)
#define GREEN2_MUL  (-BLUE_MUL/6)
#define RED_ADD     (-RED_NULL  * RED_MUL)
#define BLUE_ADD    (-BLUE_NULL * BLUE_MUL)
#define GREEN1_ADD  (-RED_ADD/2)
#define GREEN2_ADD  (-BLUE_ADD/6)
#define GRAY(val)               ng_yuv_gray[val]
#define RED(gray,red)           ng_clip[ CLIP + gray + ng_yuv_red[red] ]
#define GREEN(gray,red,blue)    ng_clip[ CLIP + gray + ng_yuv_g1[red] + \
                                                       ng_yuv_g2[blue] ]
#define BLUE(gray,blue)         ng_clip[ CLIP + gray + ng_yuv_blue[blue] ]
#define FALSE 0
#define TRUE 1
#define MAX_CONTOURS 1024
#define MAX_STACK 4096
#define MAX_VERTEX 4096
#define MAX_CONTOUR_PIXELS 4096
#define MIN_CONTOUR_PIXELS 3
#define PI 3.141592

/*
 * GLOBALS
 */
/* lookup tables */
static unsigned int  ng_yuv_gray[256];
static unsigned int  ng_yuv_red[256];
static unsigned int  ng_yuv_blue[256];
static unsigned int  ng_yuv_g1[256];
static unsigned int  ng_yuv_g2[256];

/* for color correction */
static unsigned int  ng_clip[256 + 2 * CLIP];




/*
 * PROTOTYPES
 */
static void sub_image(char *out_addr, char *before_image, char *after_image);
void Labeling(char *image);
int Push(unsigned char *stackx, unsigned char *stacky, unsigned char vx, unsigned char vy, int *top, int size);
int Pop(unsigned char *stackx, unsigned char *stacky, unsigned char *vx, unsigned char *vy, int *top);
void Find_target(char* image);
static void cim_image(char *out_addr,char *in_addr);

